<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>箭头函数</title>
</head>
<body>
<script>
    /*
        箭头函数：本身没有this,没有arguments
    */
    function fu() {
        console.log(arguments);
        console.log('普通函数');
        console.log(this);//window
    }
    fu(2);
    let obj = {
        name:'雅腾',
        fn:function () {
            console.log('执行了');
            console.log(arguments);//有
            console.log(this)//obj
        },
        //箭头函数本身没有this
        fn2:()=>{
            console.log('箭头函数');
            // console.log(arguments); //没有
            console.log(this);// window
            return 100;
        },
        fn3:()=>2,//如果箭头函数写在一行，可以省略return
        fn4:(item)=>{
            if(item>0){
                return "大"
            }else {
                return  '小'
            }
        }
    }
    //普通函数的this就看（.）前面
    obj.fn();
    obj.fn2();
    obj.fn3();
    let res2 = obj.fn4(5);
    let res = obj.fn2();
    let res1 = obj.fn3();
    console.log(res)
    console.log(res1)
    console.log(res2)

    let array = ['asfaf','ryjty'];
    //不匹配：-1 ！=-1添加不成立  匹配：0 ！=-1 条件成立
    array.find((item,index,ary)=> item.indexOf('t')!=-1)
    console.log(array.find((item)=> item.indexOf('t')!=-1));

</script>

</body>
</html>